<div class="dialog_content">
<form id="info_form" action="{:url('Link/editDo')}" method="post">
<div class="common-form">
	<table width="100%" cellpadding="2" cellspacing="1" class="table_form">

        <tr>
			<th width="100">链接分类 :</th>
			<td>
            <select name="cate_id" id="cate_id">
            <option value="">--请选择分类--</option>
            {volist name="cate_list" id="val"}
            <option value="{$val.id}" {if condition="$info['cate_id'] eq $val['id']"}selected="selected"{/if}>{$val.name}</option>
            {/volist}
            </select></td>
		</tr>
        <tr>
			<th width="100">名称 :</th>
			<td><input type="text" name="name" id="name" class="input-text" size="30" value="{$info.name}"></td>
		</tr>
        <tr>
			<th width="100">链接地址 :</th>
			<td><input type="text" name="url" id="url" class="input-text" size="30" value="{$info.url}"></td>
		</tr>
		<tr>
            <th>图片 :</th>
            <td>
            	<input type="text" name="img" id="J_img" class="input-text fl mr10" size="30" value="{$info.img}">
            	<div id="J_upload_img" class="upload_btn"><span>上传</span></div>
            </td>
		</tr>
        <tr>
			<th width="100">排序值 :</th>
			<td><input type="text" name="ordid" id="ordid" class="input-text" size="10" value="{$info.ordid}"></td>
		</tr>
		<tr>
			<th>状态 :</th>
			<td>
				<input type="radio" name="status" class="radio_style" value="1" {if condition="$info.status eq 1"} checked="checked"{/if}> 启用
				<input type="radio" name="status" class="radio_style" value="0" {if condition="$info.status eq 0"} checked="checked"{/if}> 禁用
			</td>
		</tr>
	</table>
    <input type="hidden" name="id" value="{$info.id}" />
</div>
</form>
</div>
<script src="__PUBLIC__/js/plugins/fileuploader.js"></script>
<script type="text/javascript">
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	$("#name").formValidator({onshow:"请填写链接名称",onfocus:"请填写链接名称"}).inputValidator({min:1,onerror:"请填写链接名称"}).defaultPassed();
	$("#cate_id").formValidator({onshow:"请选择分类",onfocus:"请选择分类"}).inputValidator({min:1,onerror:"请选择分类"}).defaultPassed();

	$('#info_form').ajaxForm({success:complate,dataType:'json'});
	function complate(result){
		if(result.status == 1){
			$.dialog.get(result.dialog).close();
			$.yingloujie.tip({content:result.msg});
			setTimeout(function(){window.location.reload();},1000);
		} else {
			$.yingloujie.tip({content:result.msg, icon:'alert'});
		}
	}
	//上传图片
	var uploader = new qq.FileUploaderBasic({
		allowedExtensions: ['jpg','gif','jpeg','png','bmp','pdg'],
		button: document.getElementById('J_upload_img'),
		multiple: false,
		action: "{:url('Link/ajaxUploadImg')}",
		inputName: 'img',
		forceMultipart: true, //用$_FILES

		showMessage: function(message){
			$.yingloujie.tip({content:message, icon:'error'});
		},
		onSubmit: function(id, fileName){
			$('#J_upload_img').addClass('btn_disabled').find('span').text('上传中，请稍候...');
		},
		onComplete: function(id, fileName, result){
			$('#J_upload_img').removeClass('btn_disabled').find('span').text('上传');
			if(result.status == '1'){
				$('#J_img').val(result.data);
			} else {
				$.yingloujie.tip({content:result.msg, icon:'error'});
			}
		}
	});
});
</script>
